jeeps function pointers, GPS_PPacket const correctness, GPS_Serial_[OSP]Packet -...
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Mon, 13 Nov 2023 23:33:14 +0000 (16:33 -0700)
committerGitHub <noreply@github.com>
Mon, 13 Nov 2023 23:33:14 +0000 (16:33 -0700)
* use using for jeeps function prototypes.

* const correctness wrt GPS_PPacket.

The important bit here is in gpssend.cc, Build_Serial_Packet used to rececive a 1KB packet by copy, now it is by const reference.

* delete accidentally committed file.

* rename GPS_PPacket -> GPS_Packet.

original jeeps used GPS_SXXX, GPS_OSXXX, GPS_PXXX for the structure
tag, a typedef of the structure, and a pointer to a typedef of the
structure.  In the case of GPS_PPacket this convention was no longer
followed.

* change GPS_Packet back to a structure.

* try harder to change GPS_Packet back to a struct.

* clean up GPS_Serial_[SOP]Packet.

* catch some missed renames up.

clion on linux missed some windows only renames.

17 files changed:
jeeps/gps.h
jeeps/gpsapp.cc
jeeps/gpsapp.h
jeeps/gpscom.cc
jeeps/gpsdevice.cc
jeeps/gpsdevice.h
jeeps/gpsdevice_usb.cc
jeeps/gpsread.cc
jeeps/gpsread.h
jeeps/gpsrqst.cc
jeeps/gpssend.cc
jeeps/gpssend.h
jeeps/gpsserial.cc
jeeps/gpsusbcommon.h
jeeps/gpsusbint.h
jeeps/gpsusbread.cc
jeeps/gpsusbsend.cc

index 951d8263ad485923ed3422fabe9af8c5d6964a7d..f9e9f54840c85f0f7f887ad7ede1ed6bdec16972 100644 (file)
@@ -28,21 +28,14 @@ extern int32 gps_show_bytes;
 extern char gps_categories[16][17];
 
 
-typedef struct GPS_SPacket {
-  US type;
-  uint32 n;
-  UC* data;
-} GPS_OPacket;
-
-class GPS_PPacket {
-public:
+struct GPS_Packet {
   US type{0};
   uint32 n{0};
   UC data[MAX_GPS_PACKET_SIZE]{};
 };
 
 
-typedef struct GPS_Serial_SPacket {
+struct GPS_Serial_Packet {
   UC dle;
   UC type;
   UC n;
@@ -50,15 +43,7 @@ typedef struct GPS_Serial_SPacket {
   UC chk;
   UC edle;
   UC etx;
-} GPS_Serial_OPacket, *GPS_Serial_PPacket;
-
-typedef struct GPS_SProduct_Data_Type {
-  int16 id;
-  int16 version;
-  char  desc[MAX_GPS_PACKET_SIZE];
-} GPS_OProduct_Data_Type, *GPS_PProduct_Data_Type;
-
-
+};
 
 
 typedef struct GPS_SPvt_Data_Type {
@@ -247,7 +232,7 @@ typedef struct GPS_SCourse_Limits {
 } GPS_OCourse_Limits, *GPS_PCourse_Limits;
 
 
-typedef int (*pcb_fn)(int, GPS_SWay**);
+using pcb_fn = int (*)(int, GPS_SWay**);
 
 #include "jeeps/gpsdevice.h"
 #include "jeeps/gpssend.h"
index 95e487629c64ac994dd0cd6cb95267d688b98cbb..c66ad672c88d06fcd7a69c4780b3db69b3a13304 100644 (file)
@@ -47,7 +47,7 @@ double gps_save_lon;
 #define XMIN(a,b) (a < b? a : b)
 
 static int32    GPS_A000(const char* port);
-static void   GPS_A001(GPS_PPacket& packet);
+static void   GPS_A001(const GPS_Packet& packet);
 
 
 static void   GPS_A500_Translate(UC* s, GPS_PAlmanac* alm);
@@ -201,8 +201,8 @@ int32 GPS_Init(const char* port)
 static int32 GPS_A000(const char* port)
 {
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int16 version;
   int16 id;
 
@@ -379,16 +379,16 @@ carry_on:
 ** Extract protocol capabilities
 ** This routine could do with re-writing. It's too long and obtuse.
 **
-** @param [r] packet [GPS_PPacket] A001 protocol packet
+** @param [r] packet [GPS_Packet] A001 protocol packet
 **
 ** @return [void]
 ************************************************************************/
-static void GPS_A001(GPS_PPacket& packet)
+static void GPS_A001(const GPS_Packet& packet)
 {
   US lasta=0;
 
   int32 entries = packet.n / 3;
-  UC* p = packet.data;
+  const UC* p = packet.data;
 
   for (int32 i=0; i<entries; ++i,p+=3) {
     US tag = *p;
@@ -861,8 +861,8 @@ int32 GPS_A100_Get(const char* port, GPS_PWay** way, int (*cb)(int, GPS_PWay*))
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
 
@@ -1013,8 +1013,8 @@ int32 GPS_A100_Send(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_PWay
 {
   UC data[GPS_ARB_LEN];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
 
@@ -1134,8 +1134,8 @@ int32 GPS_A101_Get(const char* port)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
 
@@ -2789,8 +2789,8 @@ int32 GPS_A200_Get(const char* port, GPS_PWay** way)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
 
@@ -2961,8 +2961,8 @@ int32 GPS_A201_Get(const char* port, GPS_PWay** way)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
 
@@ -3150,8 +3150,8 @@ int32 GPS_A200_Send(const char* port, GPS_PWay* way, int32 n)
 {
   UC data[GPS_ARB_LEN];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
   US  method;
@@ -3289,8 +3289,8 @@ int32 GPS_A201_Send(const char* port, GPS_PWay* way, int32 n)
 {
   UC data[GPS_ARB_LEN];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
   US  method;
@@ -3661,8 +3661,8 @@ int32 GPS_A300_Get(const char* port , GPS_PTrack** trk, pcb_fn /*unused*/)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
   int32 ret;
@@ -3750,8 +3750,8 @@ int32 GPS_A300_Get(const char* port , GPS_PTrack** trk, pcb_fn /*unused*/)
 int
 drain_run_cmd(gpsdevh* fd)
 {
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   static UC data[2];
 
   GPS_Util_Put_Short(data,
@@ -3795,8 +3795,8 @@ int32 GPS_A301_Get(const char* port, GPS_PTrack** trk, pcb_fn cb, int protoid)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
   US Pid_Trk_Data, Pid_Trk_Hdr, Cmnd_Transfer_Trk;
@@ -3975,8 +3975,8 @@ int32 GPS_A300_Send(const char* port, GPS_PTrack* trk, int32 n)
 {
   UC data[GPS_ARB_LEN];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
 
@@ -4067,8 +4067,8 @@ int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid,
                     gpsdevh* fd)
 {
   UC data[GPS_ARB_LEN];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
   US  method;
@@ -4204,8 +4204,8 @@ int32 GPS_A301_Send(const char* port, GPS_PTrack* trk, int32 n, int protoid,
 ************************************************************************/
 int32 GPS_D300_Get(GPS_PTrack* trk, int32 entries, gpsdevh* fd)
 {
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
 
 
@@ -4723,8 +4723,8 @@ int32 GPS_A400_Get(const char* port, GPS_PWay** way)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 n;
   int32 i;
 
@@ -4884,8 +4884,8 @@ int32 GPS_A400_Send(const char* port, GPS_PWay* way, int32 n)
 {
   UC data[GPS_ARB_LEN];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
 
@@ -5269,8 +5269,8 @@ int32 GPS_A500_Get(const char* port, GPS_PAlmanac** alm)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket trapkt;
-  GPS_PPacket recpkt;
+  GPS_Packet trapkt;
+  GPS_Packet recpkt;
   int32 i, n;
 
   if (gps_almanac_transfer == -1) {
@@ -5381,8 +5381,8 @@ int32 GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n)
 {
   UC data[GPS_ARB_LEN];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
   int32 timesent;
@@ -5731,8 +5731,8 @@ time_t GPS_A600_Get(const char* port)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   time_t ret;
 
   if (!GPS_Device_On(port, &fd)) {
@@ -5789,8 +5789,8 @@ time_t GPS_A600_Get(const char* port)
 int32 GPS_A600_Send(const char* port, time_t Time)
 {
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 posnsent=0;
   int32 ret=0;
 
@@ -5865,13 +5865,13 @@ int32 GPS_A600_Send(const char* port, time_t Time)
 **
 ** Convert date/time packet to ints
 **
-** @param [r] packet [GPS_PPacket] packet
+** @param [r] packet [GPS_Packet] packet
 **
 ** @return [time_t] gps time as unix system time
 ************************************************************************/
-time_t GPS_D600_Get(GPS_PPacket& packet)
+time_t GPS_D600_Get(const GPS_Packet& packet)
 {
-  UC* p;
+  const UC* p;
   std::tm ts{};
 
   p = packet.data;
@@ -5893,12 +5893,12 @@ time_t GPS_D600_Get(GPS_PPacket& packet)
 **
 ** make a time packet for sending to the GPS
 **
-** @param [w] packet [GPS_PPacket *] packet
+** @param [w] packet [GPS_Packet *] packet
 ** @param [r] Time [time_t] unix-style time
 **
 ** @return [void]
 ************************************************************************/
-void GPS_D600_Send(GPS_PPacket& packet, time_t Time)
+void GPS_D600_Send(GPS_Packet& packet, time_t Time)
 {
   UC data[10];
 
@@ -5937,8 +5937,8 @@ int32 GPS_A700_Get(const char* port, double* lat, double* lon)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   if (!GPS_Device_On(port, &fd)) {
     return gps_errno;
@@ -5994,8 +5994,8 @@ int32 GPS_A700_Get(const char* port, double* lat, double* lon)
 int32 GPS_A700_Send(const char* port, double lat, double lon)
 {
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   if (!GPS_Device_On(port, &fd)) {
     return gps_errno;
@@ -6032,15 +6032,15 @@ int32 GPS_A700_Send(const char* port, double lat, double lon)
 **
 ** Convert position packet to lat/long in degrees
 **
-** @param [r] packet [GPS_PPacket] packet
+** @param [r] packet [GPS_Packet] packet
 ** @param [w] lat [double *] latitude  (deg)
 ** @param [w] lon [double *] longitude (deg)
 **
 ** @return [void]
 ************************************************************************/
-void GPS_D700_Get(GPS_PPacket& packet, double* lat, double* lon)
+void GPS_D700_Get(const GPS_Packet& packet, double* lat, double* lon)
 {
-  UC* p;
+  const UC* p;
   double t;
 
   p = packet.data;
@@ -6059,13 +6059,13 @@ void GPS_D700_Get(GPS_PPacket& packet, double* lat, double* lon)
 **
 ** make a position packet for sending to the GPS
 **
-** @param [w] packet [GPS_PPacket *] packet
+** @param [w] packet [GPS_Packet *] packet
 ** @param [r] lat [double] latitude  (deg)
 ** @param [r] lon [double] longitude (deg)
 **
 ** @return [void]
 ************************************************************************/
-void GPS_D700_Send(GPS_PPacket& packet, double lat, double lon)
+void GPS_D700_Send(GPS_Packet& packet, double lat, double lon)
 {
   UC data[16];
   UC* p;
@@ -6097,8 +6097,8 @@ void GPS_D700_Send(GPS_PPacket& packet, double lat, double lon)
 int32 GPS_A800_On(const char* port, gpsdevh** fd)
 {
   static UC data[2];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   if (!GPS_Device_On(port, fd)) {
     return gps_errno;
@@ -6134,8 +6134,8 @@ int32 GPS_A800_On(const char* port, gpsdevh** fd)
 int32 GPS_A800_Off(const char* /*unused*/, gpsdevh** fd)
 {
   static UC data[2];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
 
   GPS_Util_Put_Short(data,
@@ -6169,8 +6169,8 @@ int32 GPS_A800_Off(const char* /*unused*/, gpsdevh** fd)
 ************************************************************************/
 int32 GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet)
 {
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
 
   if (!GPS_Packet_Read(*fd, &rec)) {
@@ -6203,14 +6203,14 @@ int32 GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet)
 **
 ** Convert packet to pvt structure
 **
-** @param [r] packet [GPS_PPacket] packet
+** @param [r] packet [GPS_Packet] packet
 ** @param [w] pvt [GPS_PPvt_Data *] pvt structure
 **
 ** @return [void]
 ************************************************************************/
-void GPS_D800_Get(GPS_PPacket& packet, GPS_PPvt_Data* pvt)
+void GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt)
 {
-  UC* p;
+  const UC* p;
 
   p = packet.data;
 
@@ -6270,8 +6270,8 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket trapkt;
-  GPS_PPacket recpkt;
+  GPS_Packet trapkt;
+  GPS_Packet recpkt;
   int32 i, n;
 
   if (gps_lap_transfer == -1) {
@@ -6361,7 +6361,7 @@ int32 GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb)
 **
 ** Convert packet D906, D1001, D1011, D1015 to lap structure
 **
-** @param [r] packet [GPS_PPacket] packet
+** @param [r] packet [GPS_Packet] packet
 ** @param [w] pvt [GPS_PLap *] lap structure
 **
 ** @return [void]
@@ -6486,8 +6486,8 @@ int32  GPS_A1006_Get
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket trapkt;
-  GPS_PPacket recpkt;
+  GPS_Packet trapkt;
+  GPS_Packet recpkt;
   int32 i, n;
 
   if (gps_course_transfer == -1) {
@@ -6596,8 +6596,8 @@ int32 GPS_A1006_Send(const char* /*unused*/,
                      gpsdevh* fd)
 {
   UC data[GPS_ARB_LEN];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
 
@@ -6721,8 +6721,8 @@ int32 GPS_A1007_Get(const char* port, GPS_PCourse_Lap** clp, pcb_fn cb)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket trapkt;
-  GPS_PPacket recpkt;
+  GPS_Packet trapkt;
+  GPS_Packet recpkt;
   int32 i, n;
 
   if (gps_course_lap_transfer == -1) {
@@ -6831,8 +6831,8 @@ int32 GPS_A1007_Send(const char* /*unused*/,
                      gpsdevh* fd)
 {
   UC data[GPS_ARB_LEN];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
 
@@ -6890,7 +6890,7 @@ int32 GPS_A1007_Send(const char* /*unused*/,
 **
 ** Convert packet D1007 to course lap structure
 **
-** @param [r] packet [GPS_PPacket]       packet
+** @param [r] packet [GPS_Packet]       packet
 ** @param [w] clp    [GPS_PCourse_Lap *] course lap structure
 **
 ** @return [void]
@@ -6991,8 +6991,8 @@ int32 GPS_A1008_Get(const char* port, GPS_PCourse_Point** cpt, pcb_fn cb)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket trapkt;
-  GPS_PPacket recpkt;
+  GPS_Packet trapkt;
+  GPS_Packet recpkt;
   int32 i, n;
 
   if (gps_course_point_transfer == -1) {
@@ -7102,8 +7102,8 @@ int32 GPS_A1008_Send(const char* /*unused*/,
                      gpsdevh* fd)
 {
   UC data[GPS_ARB_LEN];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   int32 i;
   int32 len;
 
@@ -7240,8 +7240,8 @@ int32 GPS_A1009_Get(const char* port, GPS_PCourse_Limits limits)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket trapkt;
-  GPS_PPacket recpkt;
+  GPS_Packet trapkt;
+  GPS_Packet recpkt;
 
   if (gps_course_limits_transfer == -1) {
     return GPS_UNSUPPORTED;
index e6d5d47711c2d52e5f92ea871acaff896b1bae83..ee03d78de1310daeb4e146092bf8be0ec2694513 100644 (file)
   int32  GPS_A500_Send(const char* port, GPS_PAlmanac* alm, int32 n);
 
   time_t GPS_A600_Get(const char* port);
-  time_t GPS_D600_Get(GPS_PPacket& packet);
+  time_t GPS_D600_Get(const GPS_Packet& packet);
   int32  GPS_A600_Send(const char* port, time_t Time);
-  void   GPS_D600_Send(GPS_PPacket& packet, time_t Time);
+  void   GPS_D600_Send(GPS_Packet& packet, time_t Time);
 
   int32  GPS_A700_Get(const char* port, double* lat, double* lon);
   int32  GPS_A700_Send(const char* port, double lat, double lon);
-  void   GPS_D700_Get(GPS_PPacket& packet, double* lat, double* lon);
-  void   GPS_D700_Send(GPS_PPacket& packet, double lat, double lon);
+  void   GPS_D700_Get(const GPS_Packet& packet, double* lat, double* lon);
+  void   GPS_D700_Send(GPS_Packet& packet, double lat, double lon);
 
   int32  GPS_A800_On(const char* port, gpsdevh** fd);
   int32  GPS_A800_Off(const char* port, gpsdevh** fd);
   int32  GPS_A800_Get(gpsdevh** fd, GPS_PPvt_Data* packet);
-  void   GPS_D800_Get(GPS_PPacket& packet, GPS_PPvt_Data* pvt);
+  void   GPS_D800_Get(const GPS_Packet& packet, GPS_PPvt_Data* pvt);
 
   int32  GPS_A906_Get(const char* port, GPS_PLap** lap, pcb_fn cb);
   void   GPS_D1011b_Get(GPS_PLap* Lap,UC* data); /*D906 D1001 D1015*/
index 6408edf38a7ddccdc093bff3bb282106098f304e..ca25a77332fe784a9bf810a126cf2cf8bd33e0c2 100644 (file)
@@ -41,8 +41,8 @@ int32 GPS_Command_Off(const char* port)
 {
   static UC data[2];
   gpsdevh* fd;
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   GPS_Util_Little();
 
index 5cfd178c007919f74c2463f30501492932ea6bdc..1294b3da8987a4b540216837e1ff823157aa7587 100644 (file)
@@ -60,27 +60,27 @@ int32  GPS_Device_Flush(gpsdevh* fd)
   return (ops->Device_Flush)(fd);
 }
 
-int32  GPS_Write_Packet(gpsdevh* fd, GPS_PPacket& packet)
+int32  GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet)
 {
   return (ops->Write_Packet)(fd, packet);
 }
 
-int32 GPS_Packet_Read(gpsdevh* fd, GPS_PPacket* packet)
+int32 GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet)
 {
   return (ops->Read_Packet)(fd, packet);
 }
 
-bool GPS_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec)
+bool GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec)
 {
   return (ops->Send_Ack)(fd, tra, rec);
 }
 
-bool GPS_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec)
+bool GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec)
 {
   return (ops->Get_Ack)(fd, tra, rec);
 }
 
-void GPS_Make_Packet(GPS_PPacket* packet, US type, UC* data, uint32 n)
+void GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n)
 {
   packet->type = type;
   if (n > 0) {
index 583f4afb7a5f2c9ac95306b395085b8284742619..f893adf274c6ae55fed7062ae9f5c5c5cf78bc06 100644 (file)
   int32  GPS_Device_Read(int32 ignored, void* ibuf, int size);
   int32  GPS_Device_Write(int32 ignored, const void* obuf, int size);
   void   GPS_Device_Error(char* hdr, ...);
-  int32  GPS_Write_Packet(gpsdevh* fd, GPS_PPacket& packet);
-  bool   GPS_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec);
-  int32  GPS_Packet_Read(gpsdevh* fd, GPS_PPacket* packet);
-  bool   GPS_Get_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec);
-
-  typedef int32(*gps_device_op)(gpsdevh*);
-  typedef int32(*gps_device_op5)(const char*, gpsdevh** fd);
-  typedef bool(*gps_device_op10)(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec);
-  typedef int32(*gps_device_op12)(gpsdevh* fd, GPS_PPacket& packet);
-  typedef int32(*gps_device_op13)(gpsdevh* fd, GPS_PPacket* packet);
+  int32  GPS_Write_Packet(gpsdevh* fd, const GPS_Packet& packet);
+  bool   GPS_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec);
+  int32  GPS_Packet_Read(gpsdevh* fd, GPS_Packet* packet);
+  bool   GPS_Get_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec);
+
+  using gps_device_op = int32 (*)(gpsdevh*);
+  using gps_device_op5 = int32 (*)(const char*, gpsdevh** fd);
+  using gps_device_op10 = bool (*)(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec);
+  using gps_device_op12 = int32 (*)(gpsdevh* fd, const GPS_Packet& packet);
+  using gps_device_op13 = int32 (*)(gpsdevh* fd, GPS_Packet* packet);
+
   typedef struct {
     gps_device_op5 Device_On;
     gps_device_op Device_Off;
index 31583c5c19124ae740be5680cb393db96e4d84b1..15e37c19eaeca0e5e7597bd2a458d8b6f0c855bb 100644 (file)
@@ -42,7 +42,7 @@ static int32 gdu_off(gpsdevh* dh)
   return gusb_close(dh);
 }
 
-static int32  gdu_read(gpsdevh* fd, GPS_PPacket* packet)
+static int32  gdu_read(gpsdevh* fd, GPS_Packet* packet)
 {
   /* Default is to eat bulk request packets. */
   return GPS_Packet_Read_usb(fd, packet, 1);
index 512c647af9c836dd81a27f02692c2f45426e544b..db9aef4bd9b8cce0b07c2cb1aeb350ac7326d0a6 100644 (file)
@@ -64,12 +64,12 @@ time_t GPS_Time_Now()
 ** Read a packet
 **
 ** @param [r] fd [int32] file descriptor
-** @param [w] packet [GPS_PPacket *] packet string
+** @param [w] packet [GPS_Packet *] packet string
 **
 ** @return [int32] number of bytes read
 **********************************************************************/
 
-int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet)
+int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet)
 {
   time_t start;
   int32 len = 0;
@@ -181,13 +181,13 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet)
 ** Check that returned packet is an ack for the packet sent
 **
 ** @param [r] fd [int32] file descriptor
-** @param [r] tra [GPS_PPacket *] packet just transmitted
-** @param [r] rec [GPS_PPacket *] packet to receive
+** @param [r] tra [GPS_Packet *] packet just transmitted
+** @param [r] rec [GPS_Packet *] packet to receive
 **
 ** @return [bool] true if ACK
 **********************************************************************/
 
-bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_PPacket *tra, GPS_PPacket *rec)
+bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec)
 {
   if (!GPS_Serial_Packet_Read(fd, rec)) {
     return false;
index 6c57f2a2e6a232f09d5f284d0b0a296df59fc9d8..d8461ac228a3b5812ed2f5c8e1c062e5318fb309 100644 (file)
@@ -5,7 +5,7 @@
 #include "jeeps/gps.h"
 
   time_t GPS_Time_Now();
-  int32  GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet);
-  bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_PPacket *tra, GPS_PPacket *rec);
+  int32  GPS_Serial_Packet_Read(gpsdevh* fd, GPS_Packet* packet);
+  bool GPS_Serial_Get_Ack(gpsdevh *fd, GPS_Packet *tra, GPS_Packet *rec);
 
 #endif
index 457eff8b10e73fdd5a1a86c54da48141dc388fb8..82a28adbceaaf041133949147344e842c1afc624 100644 (file)
@@ -69,8 +69,8 @@ int32 GPS_Rqst_Send_Time(gpsdevh* fd, time_t Time)
 ************************************************************************/
 static int32 GPS_A600_Rqst(gpsdevh* fd, time_t Time)
 {
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   switch (gps_date_time_type) {
   case pD600:
@@ -134,8 +134,8 @@ int32 GPS_Rqst_Send_Position(gpsdevh* fd, double lat, double lon)
 ************************************************************************/
 static int32 GPS_A700_Rqst(gpsdevh* fd, double lat, double lon)
 {
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   switch (gps_position_type) {
   case pD700:
index 71e7dc46a4b9b87ce6644d41c847773a18c6b4b3..07ff72e3d709d8efefebfdc1093e494bcef7062b 100644 (file)
 **
 ** Forms a complete packet to send on serial port
 *
-** @param [r] in [GPS_PPacket *] packet string with portable packet data
-** @param [w] out [GPS_Serial_PPacket *] packet string suitable for serial port
+** @param [r] in [GPS_Packet *] packet string with portable packet data
+** @param [w] out [GPS_Serial_Packet *] packet string suitable for serial port
 **
 ** @return [US] number of data bytes to send
 ************************************************************************/
 static US
-Build_Serial_Packet(GPS_PPacket in, GPS_Serial_PPacket out)
+Build_Serial_Packet(const GPS_Packet& in, GPS_Serial_Packet* out)
 {
-  UC* p;
+  const UC* p;
   UC* q;
   UC  chk = 0;
   US  bytes = 0;
@@ -111,16 +111,16 @@ DiagS(void* buf, size_t sz)
 ** Forms a complete packet to send
 **
 ** @param [w] fd [int32] file descriptor
-** @param [r] packet [GPS_PPacket] packet
+** @param [r] packet [GPS_Packet] packet
 **
 ** @return [int32] number of bytes in the packet
 ************************************************************************/
 
-int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet)
+int32 GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet)
 {
   int32 ret;
   const char* m1, *m2;
-  GPS_Serial_OPacket ser_pkt;
+  GPS_Serial_Packet ser_pkt;
   UC ser_pkt_data[MAX_GPS_PACKET_SIZE * sizeof(UC)];
   US bytes;
 
@@ -183,13 +183,13 @@ int32 GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet)
 ** Send an acknowledge packet
 **
 ** @param [w] fd [int32] file descriptor
-** @param [r] tra [GPS_PPacket *] packet to transmit
-** @param [r] rec [GPS_PPacket *] last packet received
+** @param [r] tra [GPS_Packet *] packet to transmit
+** @param [r] rec [GPS_Packet *] last packet received
 **
 ** @return [bool] success
 ************************************************************************/
 
-bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec)
+bool GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec)
 {
   UC data[2];
 
index 6a213dc88e36b6ec9783f994603a8d6383f07a1d..c478e9880242f3bf384fda5da81af1bd6e37b3ab 100644 (file)
@@ -6,10 +6,10 @@
 
 #define GPS_ARB_LEN 1024
 
-  int32  GPS_Serial_Write_Packet(gpsdevh* fd, GPS_PPacket& packet);
-  bool  GPS_Serial_Send_Ack(gpsdevh* fd, GPS_PPacket* tra, GPS_PPacket* rec);
+  int32  GPS_Serial_Write_Packet(gpsdevh* fd, const GPS_Packet& packet);
+  bool  GPS_Serial_Send_Ack(gpsdevh* fd, GPS_Packet* tra, GPS_Packet* rec);
 
-  void   GPS_Make_Packet(GPS_PPacket* packet, US type, UC* data, uint32 n);
+  void   GPS_Make_Packet(GPS_Packet* packet, US type, UC* data, uint32 n);
 
 
 #endif
index d0f8107abcf3ab36541b7715641e6f8a9b14749d..2a3cb4b2eaaaed8b681e812ea9b700d0b8c4c34a 100644 (file)
@@ -234,8 +234,8 @@ int32 GPS_Serial_Read(gpsdevh* dh, void* ibuf, int size)
 int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br)
 {
   static UC data[4];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
   win_serial_data* wsd = (win_serial_data*)fd;
 
   DWORD speed = mkspeed(br);
@@ -614,8 +614,8 @@ int32 GPS_Serial_Set_Baud_Rate(gpsdevh* fd, int br)
 
   struct termios tty;
   static UC data[4];
-  GPS_PPacket tra;
-  GPS_PPacket rec;
+  GPS_Packet tra;
+  GPS_Packet rec;
 
   speed_t speed = mkspeed(br);
 
index 8b29d4040b7257db55fcaaf771e9819bc611fa76..d1745679933e492772a37d0dbac77d86b1cccfd0 100644 (file)
@@ -23,9 +23,9 @@
  * The 'low level ops' are registered by the OS layer (win32, libusb, etc.)
  * to provide gruntwork features for the common USB layer.
  */
-typedef int (*gusb_llop_get)(garmin_usb_packet* ibuf, size_t sz);
-typedef int (*gusb_llop_send)(const garmin_usb_packet* opkt, size_t sz);
-typedef int (*gusb_llop_close)(gpsdevh* dh, bool exit_lib);
+using gusb_llop_get = int (*)(garmin_usb_packet* ibuf, size_t sz);
+using gusb_llop_send = int (*)(const garmin_usb_packet* opkt, size_t sz);
+using gusb_llop_close = int (*)(gpsdevh* dh, bool exit_lib);
 
 typedef struct gusb_llops {
   gusb_llop_get  llop_get_intr;
index 50e152263a8aa7076fc4876859a8473f3262d9ca..cba2bee1cfe13da5c0651af322698b195df1b6cf 100644 (file)
@@ -21,7 +21,7 @@
 
  */
 
-int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_PPacket* packet, int eatbulk);
-void  GPS_Make_Packet_usb(GPS_PPacket* packet, UC type, UC* data, int16 n);
-int32 GPS_Write_Packet_usb(gpsdevh* fd, GPS_PPacket& packet);
+int32 GPS_Packet_Read_usb(gpsdevh* fd, GPS_Packet* packet, int eatbulk);
+void  GPS_Make_Packet_usb(GPS_Packet* packet, UC type, UC* data, int16 n);
+int32 GPS_Write_Packet_usb(gpsdevh* fd, const GPS_Packet& packet);
 
index e6e10062df5b30e7cb333507af3c8c96a8eef7b6..59d83c352d6ef239fb9de3dc3135d1783dc668d2 100644 (file)
@@ -28,7 +28,7 @@
  * Negative on error.
  * 1 if read success - even if empty packet.
  */
-int32 GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_PPacket* packet, int eat_bulk)
+int32 GPS_Packet_Read_usb(gpsdevh* /*unused*/, GPS_Packet* packet, int eat_bulk)
 {
   int32  n;
   int32 payload_size;
index 030776587889a48f3756e9a89351626364b61175..90da93d05f8738a7820241f26473158dc02d78ce 100644 (file)
@@ -26,7 +26,7 @@
 #include <cstdio>
 
 int32
-GPS_Write_Packet_usb(gpsdevh* /*unused*/, GPS_PPacket& packet)
+GPS_Write_Packet_usb(gpsdevh* /*unused*/, const GPS_Packet& packet)
 {
   garmin_usb_packet gp;
   memset(&gp, 0, sizeof(gp));